package com.lagou.web.tp;

import com.lagou.api.service.TpService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @AUTHOR: yb.feng
 * @DATE: 2020/6/15 22:58
 * @DESC:
 */
public class TpConsumer {

    public static void main(String[] args) throws  Exception{
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:dubbo-comsumer.xml");
        TpService tpService = applicationContext.getBean("tpService",TpService.class);
        ExecutorService threadPool = Executors.newFixedThreadPool(3);
        Thread t1 = new Thread(() -> tpService.methodA());
        Thread t2 = new Thread(() -> tpService.methodB());
        Thread t3 = new Thread(() -> tpService.methodC());
        while (true){
            threadPool.execute(t1);
            threadPool.execute(t2);
            threadPool.execute(t3);
        }
    }
}
